Repository navigation
#275 - Fetch tasks from a service locator instead of the service container - #290
Merged
Merged
Conversation
…ainer - New TaskRegistry (cleverage_process.registry.task, FQCN alias): resolves the service of a task configuration (with or without "@"), code previously duplicated in ProcessManager and ProcessHelpCommand. - New internal TaskLocatorCompilerPass: builds the registry service locator from the services referenced by the process configurations (known at compile time); unknown services keep failing at runtime as before. Private task services work; non-shared ones stay non-shared. - ProcessManager and ProcessHelpCommand: new optional last constructor argument ?TaskRegistry; not passing it is deprecated (since 5.4), the tasks are then fetched from the container as before. - TaskRegistry falls back on the service container, with a deprecation (since 5.4), for a service not referenced by the process configurations. - Both fallbacks will be removed in v6.0 (#114). Documentation and tests. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… longer need to be public - Task definition reference: the `service` of a task is a service id or alias, with or without a leading `@` (the 4 equivalent forms, with the archive bridge UnzipTask as example), behaviour with an unknown service; services and aliases referenced by the process configurations can be private. - Quick start, custom tasks, common setup, good practices: `public: true` is no longer presented as required for the task services (only kept by autoconfiguration for the deprecated fallback on the service container). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
3 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #275, closes #114: the tasks are fetched from a service locator built at compile time from the process configurations, instead of the whole service container (
@service_container+$container->get(), duplicated inProcessManagerandProcessHelpCommandwith a@todo).Changes
TaskRegistry(cleverage_process.registry.task, FQCN alias):getTask(TaskConfiguration): TaskInterface, the code previously duplicated inProcessManager::initialize()andProcessHelpCommand::getTaskService()(leading@optional,TaskInterfacecheck, same error messages).TaskLocatorCompilerPass(internal): collects theserviceof every task ofclever_age_process.configurations(first argument of the process configuration registry) and registers aServiceLocatorof exactly these services (ServiceLocatorTagPass::register()). Unknown ids are left out and keep failing at runtime with the same message. Consequences:ServiceLocator::get()calls the factory each time; checked: twogetTask()calls give two instances).ProcessManagerandProcessHelpCommand: new optional last constructor argument?TaskRegistry $taskRegistry = null(the$containerargument is kept), injected inmanager.yaml/command.yaml. Without it (subclass or custom definition):Since cleverage/process-bundle 5.4: Not passing a "…\TaskRegistry" to "…::__construct()" is deprecated: the tasks are fetched from the service container. The argument will be required in v6.0., and the tasks are fetched from the container exactly as before.ProcessConfigurationRegistrysubclass):TaskRegistrygets the service from the service container withSince cleverage/process-bundle 5.4: Fetching the service "…" of the task "…" from the service container is deprecated: it is not referenced by the process configurations known when the container is compiled. It will not be found anymore in v6.0.An unknown service referenced with@still throws the containerServiceNotFoundException, as before.publicis no longer presented as required for the task services (quick start, custom tasks, common setup, good practices).5.4, as decided.#114 ("Tasks services should not be public") is handled: task services no longer need to be public. Left for v6.0, with the other deprecated code: remove the
$containerarguments and both fallbacks (the task services of the bundle and of the bridges can then be made private).Checks
vendor/, then reverted):lint:containerOK,cleverage:process:help,demo.transformeranddemo.archive.zip(bridge task referenced by its public FQCN alias) executed,cleverage_process.registry.taskgetsService(.service_locator.*).TaskRegistryTest(locator,@optional, new instance per call, deprecated fallback, unknown service with / without@, without fallback, not aTaskInterface),TaskLocatorCompilerPassTest(referenced services incl. a private one, unknown left out, no registry),ProcessManagerTaskRegistryTest(with registry: no deprecation; without: deprecation, process still runs),ProcessHelpCommandTest(deprecation without registry). ExistingProcessManager*Testnow pass aTaskRegistry.composer update(PHP 8.5): 929 tests OK, PHPStan, PHP-CS-Fixer, Rector OK. Lowest dependencies (PHP 8.2, Symfony 6.4.0): 929 tests OK.Requirements
Breaking changes
None: same constructor signatures plus an optional last argument, same behaviour without it (deprecated), tasks stay public. Deprecations only on the fallback paths. Minor: a task service referenced by a process configuration is now built through the locator (same definition, same
sharedsetting).🤖 Generated with Claude Code